import request from '../utils/request';
import { mapToParam } from '../utils';

export function getPrjProcessData({ project_name, fix_version, reporter }) {
  return request(`api/PrjProcessData/?project_name=${project_name}&fix_version=${fix_version}`, {
    method: 'GET',
    headers: {
      Accept: 'application/json',
      'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
    },
    // body: mapToParam(param),
  });
}

export function getProjectList() {
  return request('api/GetProjectList/', {
    method: 'GET',
    headers: {
      Accept: 'application/json',
      'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
    },
  });
}

// export function getReporterList() {
//   return request('api/getReporterList/', {
//     method: 'GET',
//     headers: {
//       Accept: 'application/json',
//       'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
//     },
//   });
// }

export function addQuality(addparam) {
  return request('api/CreateQualityReport/', {
    method: 'POST',
    headers: {
      Accept: 'application/json',
      'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
    },
    body: mapToParam(addparam),
  });
}
export function updateQuality(updateparam) {
  return request('api/UpdateQualityReport/', {
    method: 'POST',
    headers: {
      Accept: 'application/json',
      'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
    },
    body: mapToParam(updateparam),
  });
}

export function sendQuality(sendparam) {
  return request('api/sendQualityReport/', {
    method: 'POST',
    headers: {
      Accept: 'application/json',
      'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
    },
    body: mapToParam(sendparam),
  });
}

export function getQualityReport({ project_name, fix_version, reporter }) {
  return request(`api/getQualityReport/?project_name=${project_name}&fix_version=${fix_version}&reporter=${reporter}`, {
    method: 'GET',
    headers: {
      Accept: 'application/json',
      'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
    },
  });
}

// 需要用到的project信息
export function GetProjectList() {
  return request('api/GetProjectList/', {
    method: 'GET',
    headers: {
      Accept: 'application/json',
      'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8', // 接收x-www-form-urlencoded类型的参数
    },
  });
}
